﻿/*
 * Created by SharpDevelop.
 * User: Masy Freddy
 * Date: 15/09/2011
 * Time: 17:31
 */
namespace ProviderCinePassion
{
	using System;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Linq;
	using System.Text;
	using System.Windows;
	using System.Windows.Controls;
	using System.Windows.Data;
	using System.Windows.Documents;
	using System.Windows.Input;
	using System.Windows.Media;

	using MetaVideoEditorEvolved.Helper;

	public partial class Option : Window
	{
		ConfigurationAddIn configurationAddIn;
		
		public Option(ConfigurationAddIn configurationAddIn)
		{
			this.configurationAddIn = configurationAddIn;
			InitializeComponent();
			
			comboBoxTraceLevel.ItemsSource =  TracerLevel.GetNames(typeof(TracerLevel)).ToList();
			
			if(this.configurationAddIn != null)
			{
				comboBoxTraceLevel.Text = this.configurationAddIn.TraceLevel;
				userName.Text = this.configurationAddIn.UserName;
				passwordBox.Password = this.configurationAddIn.Password;
			}
		}
		
		private void buttonSave_Click(object sender, RoutedEventArgs e)
		{
			if(configurationAddIn == null)
			{
				configurationAddIn = new ConfigurationAddIn();
			}
			
			configurationAddIn.TraceLevel = comboBoxTraceLevel.Text;
			configurationAddIn.UserName = userName.Text;
			configurationAddIn.Password = passwordBox.Password;
			
			ConfigurationManager.Serialize(configurationAddIn);
			
			this.Close();
		}
		
		private void buttonCancel_Click(object sender, RoutedEventArgs e)
		{
			this.Close();
		}
	}
}